package com.wushi.lenovo.asia5b.app_ui.voucher.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.mvp.base.BaseAppCompatActivity;
import com.wushi.lenovo.asia5b.R;
import com.mvp.base.BaseFragmentPagerAdapter;
import com.wushi.lenovo.asia5b.app_model.voucher.VoucherType;
import com.wushi.lenovo.asia5b.app_ui.voucher.fragment.VoucherFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by zhangyuncai on 2019/1/7.
 */
public class VoucherActivity extends BaseAppCompatActivity {
    @BindView(R.id.tablayout)
    TabLayout tabLayout;
    @BindView(R.id.vp_voucher)
    ViewPager mViewPager;
    private BaseFragmentPagerAdapter mPagerAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_voucher;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
        initData();
        initEvent();
    }

    @Override
    protected void initView() {
        List<String> strings=new ArrayList<String>(){};
        strings.add(getString(R.string.voucher_valid));
        strings.add(getString(R.string.voucher_expired));
        strings.add(getString(R.string.voucher_used));
        List<Fragment> fragmentList=new ArrayList<>();
        fragmentList.add(VoucherFragment.newInstance(this, VoucherType.unused));
        fragmentList.add(VoucherFragment.newInstance(this, VoucherType.expired));
        fragmentList.add(VoucherFragment.newInstance(this, VoucherType.used));
        mPagerAdapter = new BaseFragmentPagerAdapter(getSupportFragmentManager(), fragmentList, strings);
        mViewPager.setAdapter(mPagerAdapter);
        tabLayout.setupWithViewPager(mViewPager);
        mViewPager.setOffscreenPageLimit(3);
    }

    @Override
    protected void initData() {
    }
}
